package com
{
	import mx.collections.ArrayCollection;

	public class CreatMenuTree
	{
		public function CreatMenuTree()
		{
			
		}
		public static function createdata(datas:ArrayCollection):XML{
			var menulist=new XML();
			menulist=<menulist label='root' menuid='0' state='0'
			menuseq=''  
			modulename=''   
			menulevel='0' 
			fake='true' foots='false'/>;
			for(var i:int=0;i<datas.length;i++){
				var data:Object=datas[i];
				var menuitem:XMLList=new XMLList();
				var newnodes:XML= <menuitem label={data.MENUNAME} 
				menuid={data.MENUID} 
				parentmenuid={data.PARENTMENUID}
				swf={data.SWF} 
				menulevel={data.MENULEVEL}
				swfurl={data.SWFURL}
				displayorder={data.DISPLAYORDER}
				funcdesc={data.FUNCDESC}
				forbidflag={data.FORBIDFLAG}
				nodetype={data.NODETYPE}
				subsystem={data.SUBSYSTEM}
				menuseq={data.MENUSEQ}
				ename={data.ENAME}
				state="0"
				fake="true" foots="true"/>;
				if(data.NODETYPE=="Subsystem"){
					menulist.appendChild(newnodes); 
				}
				else{
					menuitem=menulist..*.(@menuid==data.PARENTMENUID);
					if(menuitem.length()!=0){
						menuitem[0].@foots[0]="false";
						menuitem[0].appendChild(newnodes);
					}
				}
			}
			return menulist;
		}
	}
}